import axios from 'axios';
import * as actionTypes from './constants';

export const addBanner = (banner) => {
  return {
    type: actionTypes.ADDBANNER,
    banner
  }
}
export const addProductList = (productList) => {
  return {
    type: actionTypes.ADDPRODUCTLIST,
    productList
  }
}


export const fetchHomeMultidataAction = () => {

  return function (dispatch, getState) {
    axios.get('http://123.207.32.32:8000/home/multidata').then(res => {
      const banners = res.data.data.banner.list;
      const recommends = res.data.data.recommend.list;
      dispatch(addBanner(banners));
      dispatch(addProductList(recommends));
    })
  }
}